<?php

class EventController extends My_Controller_ActionEvent {

    protected $event;
    
    public function indexAction() {
        $this->setContentTitle(_('XXX_EVENT_INDEX_PAGE_TITLE'));
        $this->processEventsByInfoType();
    }

    public function showAction() {
        $this->setContentTitle(_('XXX_EVENT_SHOW_PAGE_TITLE'));
        $code = $this->_getParam('id');
        if(empty($code)) {
            $this->addError($this->translate(_('XXX_EVENT_SHOW_NOT_EXIST_ERROR')));
            $url = $this->url(array('controller' => 'event'));
            $this->_redirect($url);
        }
        $daoEvent = new Application_Model_DAO_Event();
        $this->view->event = $this->event = $event = $daoEvent->getAllEvents()
                ->where('e.code = ?', $code)
                ->query()->fetch();
        if(empty($event)) {
            $this->addError($this->translate(_('XXX_EVENT_SHOW_NOT_EXIST_ERROR')));
            $url = $this->url(array('controller' => 'event'));
            $this->_redirect($url);
        }
        $type = $event['info_type'];
        $this->_setParam('type', $type);
        $this->processEventsByInfoType();
        
    }
    
    protected function getEventListByEventTypesRestrict(Application_Model_DAO_Event $daoEvent, Zend_Db_Table_Select $select, $infoType, $startDate, $endDate, $limit = 10) {
        switch ($this->_request->getActionName()) {
            case 'show':
                $select->where('e.code != ?', $this->event['event_code']);
                break;
        }
    }
    
}

